<template>
  <div class="music-item-wrapper">
    <div class="music-item">
      <div class="music-picture" v-on:click="setMusic">
        <img v-bind:src="musicPictureUrl">
      </div>
      <div class="music-name">
        {{musicName}}
      </div>
    </div>
  </div>
</template>

<script>
import {MokeyPlayer} from "@/player/main.js"

export default {
  name: 'MusicItem',
  props: ["musicPictureUrl", "musicName", "musicData"],
  methods: {
    setMusic: function() {
      MokeyPlayer.switchMusic(this.musicData);
      MokeyPlayer.musicOn();
    }
  }
}
</script>

<style scoped>
.music-item-wrapper {
  box-sizing: content-box;
  padding: 15px 15px;
  width: 200px;
}

.music-picture {
  position: relative;
  top: 0;
  width: 200px;
  height: 200px;
  background-color: aliceblue;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.2);
  transition: top 0.3s;
  cursor: pointer;
}

.music-picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.music-picture:hover {
  top: -6px;
}

.music-name {
  margin-top: 10px;
}
</style>
